//
//  WCItemTwoTabel_headView.m
//  WC
//
//  Created by wsj2015 on 15/9/13.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCItemTwoTabel_headView.h"



#import "Macros.h"
#import "Masonry.h"
@implementation WCItemTwoTabel_headView
{
    UIButton *_picBtn;
}

-(instancetype)initWithFrame:(CGRect)frame withCatogoryArray:(NSArray *)cagoArray
{
    if (self =[super initWithFrame:frame]) {
       
       // self.backgroundColor =[UIColor redColor];
        UILabel *titleLabel =[MyUtil createLabel:CGRectMake(0, 13, 80, 22) text:@"科室选择"];
        titleLabel.textAlignment =NSTextAlignmentCenter;
        titleLabel.tag  = 500;
        [self addSubview:titleLabel];
//        CGFloat titleLabelX =CGRectGetMaxX(titleLabel.frame);
//        
//        CGRect superRc = CGRectMake(titleLabelX, 15, 80, 18);

//        WCPicker *picker =[[WCPicker alloc]initWithFrame:CGRectMake(titleLabelX, 13,100, 22) strArray:cagoArray defaultTitle:@"全部"] ;
//        picker.layer.borderWidth =1;
//        picker.layer.borderColor =[UIColor whiteColor].CGColor;
//        picker.backgroundColor =[UIColor clearColor];
//        __weak typeof(self) weakSelf =self;
//        picker.pickedBlock =^(NSString *itemStr){
//            if (weakSelf.catePickBlock) {
//            
//                weakSelf.catePickBlock(itemStr);
//            }
//        };
        UIButton *picBtn =[UIButton buttonWithType:UIButtonTypeCustom];
//        picBtn.frame  =superRc;
        [picBtn setTitle:@"全部" forState:UIControlStateNormal];
        picBtn.titleLabel.font =[UIFont systemFontOfSize:14];
        
//        picBtn.titleLabel.adjustsFontSizeToFitWidth =YES;
        picBtn.layer.borderWidth =1;
        picBtn.layer.borderColor =[UIColor whiteColor].CGColor;
//        [picBtn setBackgroundImage:[UIImage imageNamed:@"首页city_btn"] forState:UIControlStateNormal];
        picBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [picBtn addTarget:self action:@selector(pickAction:) forControlEvents:UIControlEventTouchUpInside];
        _picBtn =picBtn;
        [self addSubview:picBtn];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left);
            make.top.equalTo(self.mas_top).offset(16);
//            make.centerY.equalTo(self.mas_centerY);
            make.width.mas_equalTo(80);
            
        }];
        [picBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(titleLabel.mas_right);
            make.centerY.equalTo(titleLabel.mas_centerY);
            make.width.mas_greaterThanOrEqualTo(80);
            make.right.lessThanOrEqualTo(self.mas_right);
        }];
        
        
        
    }
    return self;

}
- (void)pickAction:(UIButton *)btn
{
    if (self.catePickBlock) {
        
        self.catePickBlock();
    }
    
    
 
}
- (void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    
    UILabel *leftLabel =[self viewWithTag:500];
    leftLabel.text = titleStr;
    
}
- (void)setBtnTitle:(NSString *)btnTitle
{
    _btnTitle =btnTitle;
    [_picBtn setTitle:btnTitle forState:UIControlStateNormal];

}

@end
